/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.querie.util;

import com.querie.collab.ItemSimilarity;
import com.querie.collab.JacItemSimilarity;
import com.querie.collab.CosineItemSimilarity;

/**
 *
 * @author a-skoshy
 */
public class QueryTrain extends Thread {

    public void run() {
        try {
            long start = System.currentTimeMillis();
            // Get elapsed time in milliseconds

            ItemSimilarity sim = null;
        QryParameters qParam = QryParameters.getInstance();
        String trainString = qParam.getValue("TRAINSESSION");
        String whereClause = " where sessionId in (" + trainString + ")";
        String algoType = qParam.getValue("ALGO");
        if (algoType.equals("jac")) {
            sim = new JacItemSimilarity();
        } else if (algoType.equals("cos")) {
            sim = new CosineItemSimilarity();
        } else {
            throw new Exception("Unknown Algorithm");
        }
        sim.processBackendForAllSessions(whereClause);
            long elapsedTimeMillis = System.currentTimeMillis() - start;
            float elapsedTimeSec = elapsedTimeMillis / 1000F;
            System.out.println("%%%%%%%%%%%%%%%Elapsed time for training" + elapsedTimeSec + " %%%%%%%%%%%%%%");
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
